package com.tenglong.teacher.ui.adapter;

import android.support.annotation.NonNull;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.ViewGroup;

import com.tenglong.teacher.R;
import com.tenglong.teacher.data.resultInfo.AnswerInfo;
import com.tenglong.teacher.data.resultInfo.RelateInfo;
import com.tenglong.teacher.ui.adapter.viewholder.RelateViewHolder;
import com.tenglong.teacher.ui.adapter.viewholder.base.BaseViewHolder;

import java.util.List;

public class RelateAnswerAdaper extends RecyclerView.Adapter<BaseViewHolder<AnswerInfo>> {
    private List<AnswerInfo> infos;
    private RelateAnswerListener listener ;

    public RelateAnswerAdaper(List<AnswerInfo> infos) {
        this.infos = infos;
    }

    @NonNull
    @Override
    public BaseViewHolder<AnswerInfo> onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
        return new RelateViewHolder(LayoutInflater.from(parent.getContext()).inflate(R.layout.relate_answer_item_layout, parent, false),listener);
    }

    @Override
    public void onBindViewHolder(@NonNull BaseViewHolder<AnswerInfo> holder, int position) {
        holder.setLayoutInfo(infos.get(position));
    }

    @Override
    public int getItemCount() {
        return infos.size();
    }


    public void setRelateAnswerListener(RelateAnswerListener listener){
        this.listener = listener;
    }

    public interface RelateAnswerListener{
        void onRelateAnswerListener(AnswerInfo info, int position);
    }
}
